#pragma once
#include <opencv/cv.h>


class MorphologicalOperation
{
public:

	enum SEType
	{
		RECT, CROSS, ELLIPSE
	};

private:

	IplConvKernel* _structElem;
	IplImage* _tempImage;

	void _createNewSE (SEType structElemType, int width, int height,
			int centerX = -1, int centerY = -1);
	void _createTempImage (const IplImage* inImage);

public:

	MorphologicalOperation (SEType structElemType = RECT, int width = 3,
			int height = 3, int centerX = -1, int centerY = -1);
	~MorphologicalOperation ();

	void changeStructElem (SEType structElemType, int width, int height,
			int centerX = -1, int centerY = -1);

	void dilate (const IplImage* inImage, IplImage* outImage, int iterations = 1);
	void erosion (const IplImage* inImage, IplImage* outImage, int iterations = 1);
	void open (const IplImage* inImage, IplImage* outImage, int iterations = 1);
	void close (const IplImage* inImage, IplImage* outImage, int iterations = 1);
	void thin (const IplImage* inImage, IplImage* outImage);
};

